//这个文件是用来书写api接口请求函数的文件
//以后我们请求获取数据，每个接口都对应一个函数去发请求

//请求获取三级分类列表数据的函数
// /api/product/getBaseCategoryList
// get
import Ajax from './ajax'
import mockAjax from './mockAjax'
export const reqCategoryList = () => {
  return mockAjax({
    url: '/categorys',
    methods: 'get'
  })
}
export const reqSearchList = () => {
  return mockAjax({
    url: '/search',
    methods: 'get'
  })
}
export const reqCategoryNav = () => {
  return mockAjax({
    url: '/categorysNav',
    methods: 'get'
  })
}
export const reqBannerList = () => {
  return mockAjax({
    url: '/bannerlist',
    methods: 'get'
  })
}
// 获取收件人
export const reqReceiver = () =>{
  return mockAjax({
    url: '/shoujianren',
    method: 'get'
  })
}

// 获取验证码
export const reqGetCode = (phone) => {
  return Ajax({
    url:`/api/user/passport/sendCode/${phone}`,
    method:'get'
  })
}

// 完成注册
export const reqUserRegister = (userInfo) => {
  return Ajax({
     url:'/api/user/passport/register',
     method:'POST',
     data:userInfo
  })
}

// 登录
export const reqUserLogin = (loginInfo) => {
  return Ajax({
     url:'/api/user/passport/login',
     method:'POST',
     data:loginInfo
  })
}
// 获取用户信息
export const reqGetUserInfo = () => {
  return Ajax({
     url:'/api/user/passport/auth/getUserInfo',
     method:'GET',
  })
}

export const reqPayInfo = (orderId) => {
  return Ajax({
    url:`/api/payment/weixin/createNative/${orderId}`,
    method:'get'
  })
}

export const reqPayStatus = (orderId) => {
  return Ajax({
    url:`/api/payment/weixin/queryPayStatus/${orderId}`,
    method:'get'
  })
}
export const reqGoodsListInfo = (searchParams) => {
  return Ajax({
    url:'/api/list',
    method:'post',
    data:searchParams
  })
}

// reqGoodsListInfo({})  //测试的时候必须携带参数，假设不知道参数是什么，至少给个空的对象

//请求获取详情数据

///api/item/{ skuId }
//get

export const reqGoodsDetailInfo = (skuId) => {
  return Ajax({
    url:`/api/item/${ skuId }`,
    method:'get'
  })
}

export const reqAddOrUpdateShopCart = (skuId,skuNum) => {
  return Ajax({
    url:`/api/cart/addToCart/${ skuId }/${ skuNum }`,
    method:'post'
  })
}
export const reqShopCartList = () => {
  return Ajax({
    url:'/api/cart/cartList',
    method:'get'
  })
}

export const reqUserLogout = () => {
  return Ajax({
    url:'/api/user/passport/logout',
    method:'get'
  })
}


// 修改单个购物车选中状态
///api/cart/checkCart/{skuId}/{isChecked}
// get

export const reqUpdateOneIsChecked = (skuId,isChecked) => {
  return Ajax({
    url:`/api/cart/checkCart/${skuId}/${isChecked}`,
    method:'get'
  })
}


//修改多个购物车选中状态
///api/cart/batchCheckCart/{isChecked}
//post
export const reqUpdateAllIsChecked = (isChecked,skuIds) => {
  return Ajax({
    url:`/api/cart/batchCheckCart/${isChecked}`,
    method:'post',
    data:skuIds
  })
} 



// 请求删除单个购物车
///api/cart/deleteCart/{skuId}
//delete
export const reqDeleteShopCart = (skuId) => {
  return Ajax({
    url:`/api/cart/deleteCart/${skuId}`,
    method:'delete'
  })
}

// 请求删除多个购物车
///api/cart/batchDeleteCart
// delete
export const reqDeleteAllShopCart = (skuIds) => {
  return Ajax({
    url:'/api/cart/batchDeleteCart',
    method:'delete',
    data:skuIds
  })
}





